﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="PurchaseOrder.aspx.cs" Inherits="Main_ServiceInvoice_TransactionFormat_PurchaseOrder" %>
<%@ Register Src="~/User Controls/PageHeading.ascx" TagName="heading" TagPrefix="acc" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="AjaxControl" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>Invoice Format</title>
    <link href="../../../Styles/accounts.css" rel="stylesheet" type="text/css" />    
  <%--  <script src="../../../Menu/js/jquery.min.js" type="text/javascript"></script>--%>
  <script src="../../../JavaScript/jquery-1.4.2.min.js" type="text/javascript"></script>
  
    <link href="../../../Styles/HorizontalTab.css" rel="stylesheet" type="text/css" />
    <script src="../../../JavaScript/HorizontalTab.js" type="text/javascript"></script>
     <script type="text/javascript">
         function isNumberKey(control_id, evt) {
             var charCode = (evt.which) ? evt.which : event.keyCode
             if (charCode > 31 && (charCode < 48 || charCode > 57) && (charCode < 45 || charCode >= 47))
                 return false;

             if (charCode == 46) {
                 var dotcount = document.getElementById(control_id).value.split('.').length - 1;
                 if (dotcount >= 1) {
                     return false;
                 }
             }
             return true;
         }
         function EnabledTabKey(id, e) {
             var keycode;
             if (window.event) {
                 keycode = window.event.keyCode;
             }
             else if (e) {
                 keycode = e.which;
             }
             else {
                 return true;
             }
             if (keycode == 9) {
                 // if is the tab key                
                 return true;
             }
             else {
                 return false;
             }
         }
         function RequiredField() {
             var Flag = true;
             if (document.getElementById("txtFormatName").value == '') {
                 alert('Specify Purchase Order Format Name');
                 document.getElementById("txtFormatName").focus();
                 Flag = false;
             }
             return Flag;
         }
         function FillZero(id) {
             var ctrlValue = document.getElementById(id).value;
             var zero = 0;
             if (ctrlValue == '') {
                 document.getElementById(id).value = parseFloat(zero).toFixed(2);
             }
             else {
                 document.getElementById(id).value = parseFloat(ctrlValue).toFixed(2);
             }
             return true;
         }
         function ServiceTaxSettingTaxAtItemLevel(id) {
             var radioButtonTax = document.getElementById(id);
             var radioButtonDiscount = document.getElementById("rbtApplyDiscount");
             var InputsTax = radioButtonTax.getElementsByTagName("input");
             var InputsDiscount = radioButtonDiscount.getElementsByTagName("input");
             for (var i = 0; i < InputsTax.length; i++) {
                 if (InputsTax[i].checked) {
                     if (InputsTax[i].value == '1') {
                         document.getElementById("panelAdditionalTax").style.display = "none"; ;
                         document.getElementById("panelServiceTax").style.display = "inline";
                         if (InputsDiscount[1].checked == true) {
                             InputsDiscount[0].checked = true;
                         }
                         InputsDiscount[1].disabled = true;                        
                     }
                     else {
                         document.getElementById("panelServiceTax").style.display = "none"; ;
                         document.getElementById("panelAdditionalTax").style.display = "inline";                         
                         InputsDiscount[1].disabled = false; 
                     }
                 }                
             }
         }         
     </script>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
  <div class="divmain">
        <acc:heading ID="header1" runat="server" HeadingText="Purchase Order" />
    </div>
   <div style="width: 90%; margin-left: 5%; margin-right: 5%; text-align:center">    
        <asp:Label ID="lblMsg" runat="server" Font-Bold="true"></asp:Label>
    </div>
    
     <asp:Panel ID="PnlAddNew" runat="server" Visible="false">
    <div style="width: 90%; margin-left: 5%; margin-right: 5%" class="tablecontent">   
    <asp:HiddenField ID="hidFormatId" runat="server" Value="0" />    
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>           
                <table style="width:100%">
                    <tr>
                        <td class="headtd" colspan="3">
                            Purchase Order Format
                        </td>
                    </tr>
                    <tr>
                        <td style="width: 25%">
                            Format Name<span style="color: Red">*</span>
                        </td>
                        <td style="width: 30%">
                            <asp:TextBox ID="txtFormatName" MaxLength="50" ToolTip="Format Name" runat="server" Width="180px" CssClass="input"></asp:TextBox>
                        </td>
                        <td style="width: 45%">
                            <asp:CheckBox ID="chkDefualt" runat="server" Text="Set as Default" />
                        </td>
                    </tr>
                </table>
            </ContentTemplate>
        </asp:UpdatePanel>
    </div>
    <div id="wrapper">               
        <ul class="tabs">
            <li><a href="javascript:void(0)" class="defaulttab" rel="tabOptions">Options</a></li>
            <li><a href="javascript:void(0)" rel="tabTaxDiscount">Tax/Discount</a></li>
            <li><a href="javascript:void(0)" rel="tabNumberSettings">Number Settings</a></li>                      
        </ul>
        <div class="tab-content" id="tabOptions" runat="server">
            <div style="margin-left: 10px;">
            <table cellpadding="2" cellspacing="2">
                <tr>
                    <td>
                        <asp:CheckBox ID="chkDescriptions" runat="server" Text="Descriptions" /> 
                           
                    </td>
                </tr>
                <tr>
                    <td>
                        <asp:CheckBox ID="chkUOM" runat="server" Text="Unit of Measurement" />
                    </td>                    
                </tr>
                <tr>
                    <td>
                        <asp:CheckBox ID="chkNarration" runat="server" Text="Narration" />
                    </td>                    
                </tr>
                <tr>
                    <td>
                        <asp:CheckBox ID="chkPreparedBy" runat="server" Text="Prepared By" />
                    </td>                    
                </tr>               
                <tr>
                    <td>
                        <asp:CheckBox ID="chkCheckedBy" runat="server" Text="Checked By" />
                    </td>                    
                </tr>
                <tr>
                    <td>
                        <asp:CheckBox ID="chkRemarks" runat="server" Text="Remarks" />
                    </td>                    
                </tr>                              
            </table>
            </div>
        </div>
         <div id="tabTaxDiscount" class="tab-content">
            <div style="margin-left:10px;">               
                <table width="50%" style="margin-bottom:5px" class="tablecontent">
                    <tr>
                        <td class="headtd">
                            Apply Discount
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <asp:RadioButtonList ID="rbtApplyDiscount" runat="server" RepeatDirection="Horizontal">
                                <asp:ListItem Text="None" Value="0" Selected="True"></asp:ListItem>
                                <asp:ListItem Text="Bill Level" Value="1"></asp:ListItem>
                                <asp:ListItem Text="Item Level" Value="2"></asp:ListItem>                                    
                            </asp:RadioButtonList>
                        </td>
                    </tr>
                </table>
                <table width="50%" class="tablecontent">
                    <tr>
                        <td class="headtd">
                            Apply Tax
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <asp:RadioButtonList ID="rbtApplyTax" runat="server" RepeatDirection="Horizontal" onclick="ServiceTaxSettingTaxAtItemLevel(this.id);">                                    
                                <asp:ListItem Text="Bill Level" Value="0" Selected="True"></asp:ListItem>
                                <asp:ListItem Text="Item Level" Value="1"></asp:ListItem>                                    
                            </asp:RadioButtonList>
                        </td>
                    </tr>
                </table>
                <br />
                <b>Tax Settings:</b>
                <br />
                <asp:Panel ID="panelAdditionalTax" runat ="server">
                    Additional Tax &nbsp;&nbsp:<asp:DropDownList ID="ddlAdditionalTax" runat="server" CssClass="dropdown"></asp:DropDownList>
                </asp:Panel>
                <asp:Panel ID="panelServiceTax" runat ="server" style="display:none;">
                    <asp:RadioButtonList ID="rbtServiceTaxSettings" runat="server" RepeatDirection="Vertical">
                        <asp:ListItem Text="Service Tax" Value="0" Selected="True"></asp:ListItem>
                        <asp:ListItem Text="Service Tax, Luxury Tax" Value="1"></asp:ListItem>
                        <asp:ListItem Text="Service Tax, VAT" Value="2"></asp:ListItem>
                    </asp:RadioButtonList>
                 </asp:Panel>
                                        
                   
            </div>
        </div>        
        <div class="tab-content" id="tabNumberSettings" runat="server">
            <div style="margin-left: 10px;">
                <table style="width: 100%">
                    <tr>
                        <td>
                            Type
                        </td>
                        <td>
                            Prefix
                        </td>
                        <td>
                            Starting No
                        </td>
                        <td>
                            Suffix
                        </td>
                        <td>
                            Width of The No.
                        </td> 
                        <td>
                            &nbsp;
                        </td>                       
                    </tr>
                    <tr>
                        <td>
                            <asp:DropDownList ID="ddlType" runat="server" CssClass="dropdown">                                
                                <asp:ListItem Value="1" Text="Automatic" Selected="True"></asp:ListItem>
                                <asp:ListItem Value="0" Text="Manual"></asp:ListItem>
                            </asp:DropDownList>
                        </td>
                        <td>
                            <asp:TextBox ID="txtPrefix" runat="server" Width="80px" CssClass="input" MaxLength="10"></asp:TextBox>
                        </td>
                        <td>
                            <asp:TextBox ID="txtStartNo" runat="server" Width="80px" CssClass="input" Text="1"
                                MaxLength="6" onKeyPress="return isNumberKey(this.id,event)" Style="text-align: right"></asp:TextBox>
                        </td>
                        <td>
                            <asp:TextBox ID="txtSuffix" runat="server" Width="80px" CssClass="input" MaxLength="10"></asp:TextBox>
                        </td>
                        <td>
                            <asp:TextBox ID="txtWidthofNo" runat="server" Width="80px" CssClass="input" MaxLength="1"
                                onKeyPress="return isNumberKey(this.id,event)" Style="text-align: right"></asp:TextBox>
                        </td>
                        <td>
                            <asp:CheckBox ID="chkResetYear" runat="server" Text="Reset Every Year" />
                        </td>
                    </tr>
                    <tr>
                        <td colspan="6">
                            &nbsp;
                        </td>
                    </tr>
                </table>
            </div>
        </div>        
    </div>
    <div style="width: 90%; margin-left: 5%; margin-right: 5%; text-align:center">  
        <asp:Button ID="btnSave" runat="server" Text="Save" CssClass="button" OnClientClick="return RequiredField();" OnClick="btnSave_Click" />&nbsp;
        <asp:Button ID="btnCancel" runat="server" Text="Cancel" CssClass="button" OnClick="btnCancel_Click" />
    </div>
    </asp:Panel>
    
     <asp:Panel ID="PnlView" runat="server" Visible="false">  
    <div style="width: 90%; margin-left: 5%; margin-right: 5%; margin-top:10px; text-align:center" >
        <asp:GridView ID="grdDisplay" runat="server" CssClass="gridview" AlternatingRowStyle-CssClass="gridview_alternate"
        AutoGenerateColumns="false" Width="100%" OnRowDataBound="grdDisplay_RowDataBound"
        DataKeyNames="FormatId" OnSelectedIndexChanged="grdDidplay_OnSelectedIndexChanged"
        >
        <Columns>
            <asp:TemplateField HeaderText="S.No.">
                <ItemTemplate>
                    <%# Container.DataItemIndex+1 %>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:BoundField HeaderText="Format Name" DataField="FormatName" ItemStyle-HorizontalAlign="Left"/>
            <asp:BoundField HeaderText="Default" DataField="SetDefault"/>
            <asp:BoundField HeaderText="Descriptions" DataField="Description"/>
            <asp:BoundField HeaderText="UOM" DataField="UOM"/>
            <asp:BoundField HeaderText="Prepared By" DataField="PreparedBy"/>
            <asp:BoundField HeaderText="Checked By" DataField="CheckedBy"/>
            <asp:BoundField HeaderText="Narration" DataField="Narration"/>
            <asp:BoundField HeaderText="Remarks" DataField="Remarks"/>
            <asp:CommandField ShowSelectButton="true" ItemStyle-HorizontalAlign="Center" HeaderText="Edit" ButtonType="Image" SelectImageUrl="~/Menu/images/Edit_user.png" />
        </Columns>
        </asp:GridView>
    </div>
    </asp:Panel>
</form>
</body>
</html>
